import '../helper/dioHelper2.dart';
import '../helper/dioHelper2.dart';

class SecurityCheck {
  int ID;
  String Guid;
  String UserId;
  int State;
  String CreateTime;
  String SType;
  String Title;
  String Members;
  String Region;
  String CheckItems;
  String Content;
  String Problems;
  String Works;
  String Remark;
  String ExamQM;
  String ExamQMTM;
  String BZ1;
  String BZ2;
  String BZ3;

  SecurityCheck(
      this.ID,
      this.Guid,
      this.UserId,
      this.State,
      this.CreateTime,
      this.SType,
      this.Title,
      this.Members,
      this.Region,
      this.CheckItems,
      this.Content,
      this.Problems,
      this.Works,
      this.Remark,
      this.ExamQM,
      this.ExamQMTM,
      this.BZ1,
      this.BZ2,
      this.BZ3);
  SecurityCheck.fromJson(Map<String, dynamic> json)
      : ID = json["ID"],
        Guid = json["Guid"],
        UserId = json["UserId"],
        State = json["State"],
        CreateTime = json["CreateTime"],
        SType = json["SType"],
        Title = json["Title"],
        Members = json["Members"],
        Region = json["Region"],
        CheckItems = json["CheckItems"],
        Content = json["Content"],
        Problems = json["Problems"],
        Works = json["Works"],
        Remark = json["Remark"],
        ExamQM = json["ExamQM"],
        ExamQMTM = json["ExamQMTM"],
        BZ1 = json["BZ1"],
        BZ2 = json["BZ2"],
        BZ3 = json["BZ3"];
  Map<String, dynamic> toJson() => {
        'ID': ID,
        'Guid': Guid,
        'UserId': UserId,
        'State': State,
        'CreateTime': CreateTime,
        'SType': SType,
        'Title': Title,
        'Members': Members,
        'Region': Region,
        'CheckItems': CheckItems,
        'Content': Content,
        'Problems': Problems,
        'Works': Works,
        'Remark': Remark,
        'ExamQM': ExamQM,
        'ExamQMTM': ExamQMTM,
        'BZ1': BZ1,
        'BZ2': BZ2,
        'BZ3': BZ3,
      };

  static Future<bool> Add(SecurityCheck x1) async {
    var response = await DioHelper.Post("/SecurityCheck/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(SecurityCheck x1) async {
    var response = await DioHelper.Post("/SecurityCheck/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(SecurityCheck x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/SecurityCheck/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<SecurityCheck?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/SecurityCheck/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200)
      return new SecurityCheck.fromJson(response.data);
    return null;
  }

  static Future<SecurityCheck?> GetByID(int ID) async {
    var response =
        await DioHelper.Get("/SecurityCheck/GetByID?ID=" + ID.toString(), {});

    if (response.statusCode == 200)
      return new SecurityCheck.fromJson(response.data);
    return null;
  }

  static Future<List<SecurityCheck>> GetList(
      int pageIndex, int pageSize) async {
    var response = await DioHelper.Get(
        "/SecurityCheck/GetList?p1=" +
            pageIndex.toString() +
            "&ps=" +
            pageSize.toString(),
        {});

    var list1 = <SecurityCheck>[];
    if (response.statusCode == 200) {
      //print(response.data);
      for (var x in response.data) {
        list1.add(new SecurityCheck.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<SecurityCheck>> GetAllList() async {
    var response = await DioHelper.Get("/SecurityCheck/GetAllList", {});
    var list1 = <SecurityCheck>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new SecurityCheck.fromJson(x));
      }
    }
    return list1;
  }
}
